package cn.tedu.csmall.product.config;

import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
import javax.validation.Validator;

@Slf4j
@Configuration
public class ValidationConfiguration {
    @Bean
    public Validator validator(){//                                           配置快速失败
        return Validation.byProvider(HibernateValidator.class).configure().failFast(true).buildValidatorFactory().getValidator();
    }
    public ValidationConfiguration() {
        log.debug("创建配置类对象：ValidationConfiguration");
    }
}
